package com.health.mapp.impl;

import org.apache.commons.lang3.StringUtils;

import com.health.db.service.sm.IAdvertisementListService;
import com.health.mapp.bean.Header;
import com.health.mapp.bean.UpdateAdvertiseReadAmountReq;
import com.health.mapp.bean.UpdateAdvertiseReadAmountResp;
import com.health.mapp.utils.Response;
import com.health.mapp.utils.ResultCode;
/**
 * 更新广告阅读量
 * @author yuchong
 *
 */
public class UpdateAdvertiseReadAmountImpl implements ActionInterface {

	private IAdvertisementListService advertisementListService  ;

	@Override
	public Response execute(Header header, Object reqBean) throws Exception {
	 
		
		UpdateAdvertiseReadAmountReq req = (UpdateAdvertiseReadAmountReq) reqBean;
		UpdateAdvertiseReadAmountResp _resp = new UpdateAdvertiseReadAmountResp();
		
		if (StringUtils.isNumeric(req.getAdviceId())) {
			advertisementListService.updateReadAmount(Long.valueOf(req.getAdviceId()));
			
		}else if (StringUtils.isNumeric(req.getBannerId())) {
			advertisementListService.updateReadAmount(Long.valueOf(req.getBannerId()));
			
		}else{
			_resp.setErrorCode(ResultCode.OPERATION_LAKE_PARAMETER_ERROR);
			_resp.setErrorMsg(ResultCode.OPERATION_LAKE_PARAMETER_ERROR_NOTE);
			return _resp;
		}
		return _resp;
	}

	public IAdvertisementListService getAdvertisementListService() {
		return advertisementListService;
	}

	public void setAdvertisementListService(
			IAdvertisementListService advertisementListService) {
		this.advertisementListService = advertisementListService;
	}

}
